package chapter04

import scala.collection.mutable

/**
 * @program lu-scala01
 * @description:  可变集合
 * @author: zhanglu
 * @create: 2022-04-08 22:10:00
 */
object Lu07_MutableSet {

  def main(args: Array[String]): Unit = {
    val s1 = mutable.Set(1, 2, 3, 2, 4)
    println(s1)

    s1 += 5
    println(s1)

    val s2 = s1 + 6
    println(s2)

    s2 -= 1
    println(s2)

    s1.add(6)
    println(s1)

    s1.remove(6)  //删除值
    println(s1)

    val s3 = s1 ++ mutable.Set(8, 9)
    println(s3)

    s1 ++= mutable.Set(8, 9)
    println(s1)

  }

}
